<?PHP

	$GLOBALS['TPL_FORM_ROW_COLOR'] = 'td1';
	class tpl_form {
		
		public static function row_wrapper($html,$fieldname,$label='',$desc='',$options=array(),$error){
			if(!empty($label)) $label = "<label for='inob".$fieldname."'>".$label.'</label>';
			if(!empty($desc)) $desc = "<div class='instructions'>".$desc.'</div>';
			
			if(!empty($error))
				$error = '<div class="small_error_text">'.$error.'</div>';
			
			$GLOBALS['TPL_FORM_ROW_COLOR'] = ($GLOBALS['TPL_FORM_ROW_COLOR'] == 'td2' ? 'td1' : 'td2');
			
			return '<tr><td width="50%" class="'.$GLOBALS['TPL_FORM_ROW_COLOR'].'">'.$label.$desc.$error.'</td><td class="'.$GLOBALS['TPL_FORM_ROW_COLOR'].'">'.$html.'</td></tr>';			
		}
		
		public static function text_password_file($type,$fieldname,$default=''){
			return<<<EOV
<div class='input_container_blur' id='input{$fieldname}'><input type='{$type}' value='{$default}' name='{$fieldname}' id='inob{$fieldname}' class='input_box' onfocus="this.className='input_box_focus';" onblur="this.className='input_box';" /></div>		
EOV;
		}
		
		public static function checkbox($fieldname,$default=true){
			return tpl_form::select($fieldname,array($GLOBALS['LANG']->lang_formcommon->yes=>'1',$GLOBALS['LANG']->lang_formcommon->no=>''),($default ? 1 : ''));
		}
		
		public static function select($fieldname,$options,$default=''){
			
			$option_html = '';
			foreach($options as $label=>$value){
				$sel = ($value == $default) ? ' selected="true"' : '';
				$option_html .= "<option value='$value'$sel>$label</option>";
			}
			
			return<<<EOV
<select	name='$fieldname'>
	{$option_html}
</select>
EOV;
		}
		
	}
?>